package com.yt.order.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yt.order.models.bo.WorkOrderFilterBO;
import com.yt.order.models.bo.WorkOrderInfoBO;
import com.yt.order.models.dto.WorkOrderInfoDTO;
import com.yt.order.models.vo.EmployeeCommissionStatVO;
import com.yt.order.models.vo.WorkOrderInfoVO;
import io.lettuce.core.dynamic.annotation.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 工单信息映射
 *
 * @author chen
 * @Date 2025-09-05 18:26:57
 */
public interface WorkOrderInfoMapper extends BaseMapper<WorkOrderInfoDTO> {
    WorkOrderInfoVO selectVoById(Long id);

    List<WorkOrderInfoVO> selectPageVo(
            Page<WorkOrderInfoVO> page,
            @Param("bo") WorkOrderInfoBO bo);

    List<WorkOrderInfoVO> selectVoByTitle(String title);

        // 按状态统计
        List<Map<String, Object>> countByStatus(
                @Param("status") Integer status,
                @Param("payStatus") Integer payStatus,
                @Param("type") Integer type,
                @Param("startTime") Date startTime,
                @Param("endTime") Date endTime,
                @Param("dispatcherId") Long dispatcherId
        );

        // 按时间趋势统计
        List<Map<String, Object>> countByTime(
                @Param("status") Integer status,
                @Param("payStatus") Integer payStatus,
                @Param("type") Integer type,
                @Param("startTime") Date startTime,
                @Param("endTime") Date endTime,
                @Param("dispatcherId") Long dispatcherId
        );

        // 按类型统计
        List<Map<String, Object>> countByType(
                @Param("status") Integer status,
                @Param("payStatus") Integer payStatus,
                @Param("startTime") Date startTime,
                @Param("endTime") Date endTime,
                @Param("dispatcherId") Long dispatcherId
        );
    List<WorkOrderInfoVO> selectByFilter(WorkOrderFilterBO bo);

    List<WorkOrderInfoVO> selectPageVoByTitle(Page<WorkOrderInfoVO> page, @Param("title") String title);

    List<WorkOrderInfoVO> selectUnassignedPage(Page<WorkOrderInfoVO> page, @Param("bo") WorkOrderInfoBO bo);


    EmployeeCommissionStatVO statEmployeeCommission(
            @Param("employeeId") Long employeeId,
            @Param("startTime") Date startTime,
            @Param("endTime") Date endTime);



    int archiveCompletedOrders();
}
